package cn.ljh.student.service.impl;
import cn.ljh.student.dao.UserMapper;
import cn.ljh.student.pojo.User;
import cn.ljh.student.service.UserService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    public User getUserById(String id)throws Exception{
        return userMapper.getUserById(id);
    }

    public List<User>	getUserListByMap(Map<String,Object> param)throws Exception{
        return userMapper.getUserListByMap(param);
    }

    public Integer getUserCountByMap(Map<String,Object> param)throws Exception{
        return userMapper.getUserCountByMap(param);
    }

    public Integer qdtxAddUser(User user)throws Exception{
            //user.setCreatedTime(new Date());
            return userMapper.insertUser(user);
    }

    public Integer qdtxModifyUser(User user)throws Exception{
        //user.setUpdatedTime(new Date());
        return userMapper.updateUser(user);
    }

    public Integer qdtxDeleteUserById(String id)throws Exception{
        return userMapper.deleteUserById(id);
    }

    public Integer qdtxBatchDeleteUser(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return userMapper.batchDeleteUser(param);
    }


}
